//
// Created by moonlight on 25-7-17.
//
#include <iostream>
#include <vector>
#include <string>
#include <deque>
#include <algorithm>
#include <ctime>
//评委打分案例
using namespace std;

class Person {
public:
    string m_name;
    int m_score;
    Person(string name, int score) {
        this->m_name = name;
        this->m_score = score;
    }
};
void createPersons(vector<Person>& persons) {
    string nameSeed = "ABCDE";
    for (int i = 0; i < 5; i++) {
        string name = "选手";
        name+= nameSeed.at(i);
        int score = 0;
        Person person(name, score);
        persons.push_back(person);
    }
}
void setScore(vector<Person>& persons) {
    for (vector<Person>::iterator it = persons.begin(); it != persons.end(); it++) {
        //deque存放分数
        deque<int> scores;
        for (int i = 0; i < 10; i++) {
            int score = rand() % 41+60;
            scores.push_back(score);
        }
        sort(scores.begin(), scores.end());
        scores.pop_front();
        scores.pop_back();
        int sum = 0;
        for (int i = 0; i < scores.size(); i++) {
            sum += scores[i];
        }
        int avg = sum / scores.size();
        it->m_score = avg;
    }
}
void showScore(vector<Person>& persons) {
    for (vector<Person>::iterator it = persons.begin(); it != persons.end();it++) {
        cout << it->m_name << " " << it->m_score << endl;
    }
}
int main() {
    srand((unsigned int)time(NULL));
    //1.创建五名选手
    vector<Person> people;
    createPersons(people);
    //测试
    // for (vector<Person>::iterator it = people.begin(); it != people.end(); it++) {
    //     cout << (*it).m_name << endl;
    //     cout << (*it).m_score << endl;
    // }
    //2.给五名选手打分
    setScore( people);
    //3.显示最后得分
    showScore(people);
    cout << "Hello World!" << endl;
} 